<template>
	<div class="p_20 indexBanner">
		<el-dialog :visible.sync="isShow" :close-on-click-modal="false" @close="closeDialog">
			<!-- <el-divider></el-divider> -->
			<el-form :model="form" label-width="80px">
				<el-form-item label="岗位名">
					<el-input v-model="form.title" class="w_400"></el-input>
				</el-form-item>
				<el-form-item label="岗位类型">
					<!-- <el-input v-model="form.banner_title" class="w_400"></el-input> -->
					<el-select v-model="form.type">
						<el-option label="校园招聘" :value="1"></el-option>
						<el-option label="社会招聘" :value="2"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="岗位职责">
					<el-input v-model="form.responsibility" class="w_400" type="textarea" :rows="5"></el-input>
				</el-form-item>
				<el-form-item label="任职资格">
					<el-input v-model="form.qualification" class="w_400" type="textarea" :rows="5"></el-input>
				</el-form-item>
				<el-form-item label="简历投递方式">
					<el-input v-model="form.methods" class="w_400" type="textarea" :rows="5"></el-input>
				</el-form-item>
				<!-- <el-form-item label="图片">
					<el-upload class="avatar-uploader" :action="imgBaseURL" :show-file-list="false" name="image" :on-success="handleAvatarSuccess">
						<img v-if="imageUrl" :src="imageUrl" class="avatar">
						<i v-else class="el-icon-plus avatar-uploader-icon"></i>
						<div slot="tip" class="el-upload__tip">推荐尺寸：123123 x 312312 </div>
					</el-upload>
				</el-form-item>
				<el-form-item label="排序">
					<el-input v-model="form.sort" class="w_250"></el-input>
					<span>（数字越大越靠前）</span>
				</el-form-item>
				<el-form-item label="更多链接">
					<el-input v-model="form.url" class="w_400"></el-input>
					<span>（请将http://一并填入）</span>
				</el-form-item> -->
				<!-- <el-form-item label="语言">
					<el-input v-model="form.language" class="w_400"></el-input>
					<el-select v-model="form.language">
						<el-option label="cn" value="cn">cn</el-option>
						<el-option label="en" value="en">en</el-option>
					</el-select>
				</el-form-item> -->
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="closeDialog">取 消</el-button>
				<el-button type="primary" @click="submit">确 定</el-button>
			</span>
		</el-dialog>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				isShow: false,
				form: {
					id:'',
					title:'',
					type:'',
					responsibility:'',
					qualification:'',
					methods:'',
					language:0
				},

				//图片上传
				imageUrl: '',
				// dialogVisible: false,
				// disabled: false
			}
		},
		methods: {
			//提交
			submit(){
				
				let params = this.form;
				params.language = this.$store.getters.getLanguage
				console.log(params);
				if(this.form.id) {
					this.edit(params);
				}else {
					this.add(params);
				}
			},
			
			
			//新增
			add(params){
				this.axiosGets('Job/jobAdd', params , res => {
					if(res.data.code === 0) {
						this.msgSuccess(res.data.message);
						this.$parent.getTableData();
						this.isShow = false;
					}
				})
			},
			
			//编辑
			edit(params) {
				this.axiosGets('Job/jobEdit', params , res => {
					if(res.data.code === 0) {
						this.msgSuccess(res.data.message);
						this.$parent.getTableData();
						this.isShow = false;
					}
				})
			},


			//图片上传
			handleAvatarSuccess(res) {
				console.log(res);
				// console.log(file);
				//图片id
				this.form.image_id = res.data.id;
				//图片url
				this.imageUrl = this.imgURL + res.data.image_url;
				// this.form.url = res.data.image_url;
				// this.dialogVisible = true;
			},
			
			//关闭窗口 清空数据
			closeDialog(){
				this.form = {
					banner_id:'',
					banner_title:'',
					image_id:'',
					url:'',
					sort:0,
					language:'cn'
				}
				this.imageUrl = ''
				this.isShow = false;
			}
		}
	}
</script>

<style scoped>

</style>
